<?php

class Tools {

		public static function encodeString($var) {
			$var = utf8_encode($var);
			return $var;
		}
		public static function formatDate($var, $arg) {
			date_default_timezone_set('UTC');
			$var=explode("-",$var);
			$Y=$var[0];
			$M=$var[1];
			$D=$var[2];
			$timestamp = mktime(0, 0, 0, $M, 1, 2005);
			$date = date('M', $timestamp);
			$date .= '. '.$D;
			switch ($arg) {
				case 'full':
				return $date;
				break;
				case 'year':
				return $Y;
				break;
			}
		}
		
		public static function removeDir($path) {
			if (is_dir($path)) {
				$path = rtrim($path, '/') . '/';
				$items = glob($path . '*');
				foreach($items as $item) {
					is_dir($item) ? removeDir($item) : unlink($item);
				}
				rmdir($path);
			}
		}
		
		public static function dump($data) {
			ob_start();
			var_dump($data);
			$dp_data_dump = ob_get_contents();
			ob_end_clean();
			echo sprintf('<pre>%s</pre>', $dp_data_dump);
		}

	}

?>